package com.bright.hxj.cwduijie.service.impl;

import com.bright.hxj.cwduijie.enums.DataApi;
import com.bright.hxj.cwduijie.pojo.bo.ApiDataCollection;
import com.bright.hxj.cwduijie.pojo.po.IncomeDetail;
import com.bright.hxj.cwduijie.pojo.query.DuijieQuery;
import com.bright.hxj.cwduijie.repository.IncomeDetailRepository;
import com.bright.hxj.cwduijie.service.AbstractMonthlyReportApiService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
 * @Author hxj
 * @Date 2025/2/21 16:01
 * @Description
 */
@Component
@RequiredArgsConstructor
public class ApiIncomeDetailServiceImpl extends AbstractMonthlyReportApiService<IncomeDetail, IncomeDetail> {

    private final IncomeDetailRepository repo;

    @Override
    protected void getData(ApiDataCollection apiDataCollection, DuijieQuery duijieQuery) {
        apiDataCollection.setIncomeDetailMap(Collections.singletonMap("", getNeedDuijieData(duijieQuery)));
    }

    @Override
    public JpaSpecificationExecutor getJpaSpecificationExecutor() {
        return repo;
    }

    @Override
    public DataApi getDataApi() {
        return DataApi.INCOME_DETAIL;
    }

    @Override
    public Function<IncomeDetail, Integer> getIdFunc() {
        return IncomeDetail::getId;
    }

    @Override
    public Function<ApiDataCollection, Map<String, List<IncomeDetail>>> getDataFunc() {
        return ApiDataCollection::getIncomeDetailMap;
    }

    @Override
    public Function<IncomeDetail, IncomeDetail> getConverterFunc() {
        return Function.identity();
    }
}
